import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns : BasicColumn[] = [
	/* {
		title: '创建日期',
		align: "center",
		dataIndex: 'createTime',
		customRender: ({ text }) => {
			return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
		},
	}, */
	/* 	{
			title: '商家类型',
			align: "center",
			dataIndex: 'shopType_dictText'
		}, */
	{
		title: '酒店名称',
		align: "center",
		dataIndex: 'shoptitle'
	},
	{
		title: '酒店地址',
		align: "center",
		dataIndex: 'address'
	},
	{
		title: '联系人',
		align: "center",
		dataIndex: 'extinfors',
		customRender: ({ text, column }) => {
			if (text.indexOf("concacttelUserName") > -1) {
				let remark = JSON.parse(text).concacttelUserName
				if (!remark) {
					remark = JSON.parse((JSON.parse(text))).concacttelUserName
				}
				return remark;
			} else {
				return ""
			}


		}
	},
	{
		title: '联系电话',
		align: "center",
		dataIndex: 'concacttel'
	},
	/* {
	  title: '经纬度',
	  align:"center",
	  dataIndex: 'lotAndLat'
	 }, */
	/* 	{
			title: '产品数量',
			align: "center",
			sorter: true,
			dataIndex: 'pdtNum'
		},
		{
			title: '总销售额',
			align: "center",
			sorter: true,
			dataIndex: 'salesTotal'
		},
		{
			title: '核销总额',
			align: "center",
			sorter: true,
			dataIndex: 'chargeOff'
		},
		{
			title: '未核销总额',
			align: "center",
			sorter: true,
			dataIndex: 'unchargeOff'
		}, */
	/* 	{
			title: '商家介绍',
			align: "center",
			dataIndex: 'msg'
		}, */
	/* 	{
			title: '核销用户数',
			align: "center",
			dataIndex: 'verificationNum'
		},
		{
			title: '租户',
			align: "center",
			dataIndex: 'tenantId'
		}, */
];
//查询数据
export const searchFormSchema : FormSchema[] = [
	{
		label: "所在城市",
		field: 'shopType',
		component: 'JAreaSelect',
		/* 		componentProps: { async: true, parentCode: 'A02' }, */
		//colProps: {span: 6},
	},
	{
		label: "商家名称",
		field: 'title',
		component: 'Input',
		//colProps: {span: 6},
	},
];
//表单数据
export const formSchema : FormSchema[] = [
	/* 	{
			label: '商家类型',
			field: 'shopType',
			component: 'JDictSelectTag',
			componentProps: {
				dictCode: "sys_category,name,id,pid='1725039372530704385'"
			},
		}, */
	{
		label: '商家名称',
		field: 'title',
		component: 'Input',
	},
	{
		label: "所在城市",
		field: 'cityId',
		component: 'JAreaSelect',
		/* 	componentProps: { async: true, parentCode: 'A02' }, */
		//colProps: {span: 6},
	},
	{
		label: '经纬度',
		field: 'lotAndLat',
		component: 'Input',
		slot: 'lotAndLat'
	},
	{
		label: '商家地址',
		field: 'address',
		component: 'Input',
	},
	{
		label: '资质图片',
		field: 'imgs',
		component: 'JImageUpload',
		helpMessage: '最多上传10张图片',
		componentProps: {
			fileMax: 10
		},
	},
	{
		label: '商家介绍',
		field: 'msg',
		component: 'JEditor',
	},
	/* {
	  label: '产品数量',
	  field: 'pdtNum',
	  component: 'Input',
	  dynamicRules: ({model,schema}) => {
			return [
				   { required: false},
				   { pattern: /^-?\d+$/, message: '请输入整数!'},
			];
	   },
	},
	{
	  label: '核销用户数',
	  field: 'verificationNum',
	  component: 'InputNumber',
	}, */
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];
export const formHotelSchema : FormSchema[] = [

	{
		field: 'cityId',
		label: '选择城市',
		component: 'JAreaSelect',
	},
	/* {
	  label: '租户ID',
	  field: 'tenantid',
	  component: 'JSearchSelect',
	  componentProps:{
		 dict:"sys_tenant,name,id"
	  },
	  dynamicRules: ({model,schema}) => {
			return [
				   { required: true, message: '请输入租户ID!'},
			];
	   },
	}, */
	{
		label: '酒店名称',
		field: 'shoptitle',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入酒店名称!' },
			];
		},
	},
	{
		label: '联系人',
		field: 'concacttelUserName',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入联系人!' },
			];
		},
	},
	{
		label: '联系电话',
		field: 'concacttel',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入联系电话!' },
			];
		},
	},
	{
		label: '经纬度',
		field: 'gis',
		component: 'Input',
		slot: 'lotAndLat',
		required: true

	},

	{
		label: '地址',
		field: 'address',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入地址!' },
			];
		},
	},
	{
		label: '封面图片',
		field: 'cover',
		component: 'JImageUpload',
		componentProps: {
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请上传封面图片!' },
			];
		},
	},
	{
		label: '介绍',
		field: 'description',
		component: 'JEditor',//TODO 注意string转换问题
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入介绍!' },
			];
		},
	},
	/*  {
		label: '其余属性',
		field: 'extinfors',
		component: 'InputTextArea',//TODO 注意string转换问题
		dynamicRules: ({model,schema}) => {
			  return [
					 { required: true, message: '请输入其余属性!'},
			  ];
		 },
	  }, */
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
]
//子表列表数据
export const coupleShopRoomColumns : BasicColumn[] = [
	{
		title: '房间号',
		align: "center",
		dataIndex: 'title'
	},
	{
		title: '房间类别',
		align: "center",
		dataIndex: 'roomType_dictText'
	},
	{
		title: '房间图片',
		align: "center",
		dataIndex: 'img',
		customRender: render.renderImage,
	},
	{
		title: '房间介绍',
		align: "center",
		dataIndex: 'msg'
	},
	{
		title: '房间价格',
		align: "center",
		sorter: true,
		dataIndex: 'price'
	},
/* 	{
		title: '主表id',
		align: "center",
		dataIndex: 'mainId_dictText'
	},
	{
		title: '租户',
		align: "center",
		dataIndex: 'tenantId_dictText'
	}, */
	{
		title: '入住次数',
		align: "center",
		dataIndex: 'checkIdNum'
	},
];
//子表表单数据
export const coupleShopRoomFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '房间号',
		field: 'title',
		component: 'Input',
	},
	{
		label: '房间类别',
		field: 'roomType',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "hotel_room_type"
		},
	},
	{
		label: '房间图片',
		field: 'img',
		component: 'JImageUpload',
		componentProps: {
		},
	},
	{
		label: '房间介绍',
		field: 'msg',
		component: 'InputTextArea',
	},
	{
		label: '房间价格',
		field: 'price',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: false },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
];
//子表列表数据
export const coupleShopPdtColumns : BasicColumn[] = [
	{
		title: '发布时间',
		align: "center",
		dataIndex: 'createTime'
	},
	{
		title: '标题',
		align: "center",
		dataIndex: 'title'
	},
	{
		title: '市场价',
		align: "center",
		sorter: true,
		dataIndex: 'deduction'
	},
	{
		title: '售价',
		align: "center",
		sorter: true,
		dataIndex: 'price'
	},
	{
		title: '商家',
		align: "center",
		dataIndex: 'shopId_dictText'
	},
	{
		title: '销量',
		align: "center",
		sorter: true,
		dataIndex: 'salesQuantity'
	},
	{
		title: '已核销',
		align: "center",
		sorter: true,
		dataIndex: 'cancelledNum'
	},
	{
		title: '超时未核销',
		align: "center",
		sorter: true,
		dataIndex: 'uncancelledNum'
	},
	{
		title: '过期时间',
		align: "center",
		sorter: true,
		dataIndex: 'expirationTime'
	},
	{
		title: '租户',
		align: "center",
		dataIndex: 'tenantId'
	},
];
//子表表单数据
export const coupleShopPdtFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: '标题',
		field: 'title',
		component: 'Input',
	},
	{
		label: '市场价',
		field: 'deduction',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: false },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '售价',
		field: 'price',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: false },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '结算价',
		field: 'settlementPrice',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: false },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '产品图片',
		field: 'imgs',
		component: 'JUpload',
		helpMessage: '最多上传5张图片',
		componentProps: {
			fileType: UploadTypeEnum.image,
			maxCount: 5,
		}
	},
	{
		label: '产品类型',
		field: 'pdtCategory',
		component: 'JSearchSelect',
		componentProps: {
			dict: "pdt_category"
		},
	},
	{
		label: '佣金分配方式',
		field: 'commissionType',
		component: 'JSearchSelect',
		componentProps: {
			dict: "commission_type"
		},
	},
	{
		label: '核销过期时间',
		field: 'expirationTime',
		component: 'DatePicker',
		componentProps: {
			showTime: true,
			valueFormat: 'YYYY-MM-DD HH:mm:ss'
		},
	},
	{
		label: '产品详情',
		field: 'msg',
		component: 'JEditor',
	},
];
//子表列表数据
export const bsHotelroompriceColumns : BasicColumn[] = [
	{
		title: 'trash',
		align: "center",
		dataIndex: 'trash'
	},
	{
		title: '级别类型。standar：标间；comfort：舒适；rich：豪华；economic：经济',
		align: "center",
		dataIndex: 'leveltype_dictText'
	},
	{
		title: '第几天费用',
		align: "center",
		dataIndex: 'daynum'
	},
	{
		title: '房价金额',
		align: "center",
		dataIndex: 'price'
	},
	{
		title: '创建时间',
		align: "center",
		dataIndex: 'createtime'
	},
	{
		title: '图片',
		align: "center",
		dataIndex: 'images',
		customRender: render.renderImage,
	},
];
//子表表单数据
export const bsHotelroompriceFormSchema : FormSchema[] = [
	// TODO 子表隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
	{
		label: 'trash',
		field: 'trash',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入trash!' },
			];
		},
	},
	{
		label: '级别类型。standar：标间；comfort：舒适；rich：豪华；economic：经济',
		field: 'leveltype',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "leveltype"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入级别类型。standar：标间；comfort：舒适；rich：豪华；economic：经济!' },
			];
		},
	},
	{
		label: '第几天费用',
		field: 'daynum',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入第几天费用!' },
				{ pattern: /^-?\d+$/, message: '请输入整数!' },
			];
		},
	},
	{
		label: '房价金额',
		field: 'price',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入房价金额!' },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '图片',
		field: 'images',
		component: 'JImageUpload',
		componentProps: {
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入图片!' },
			];
		},
	},
];
/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}